*********************
* FIGURES B3 AND B4 *
*********************

/*
This do-file converts the final datasets into four new short datasets that
we use to generate Figures B3 and B4. Please change the links to directories
to your own directories.
*/


********************************************************************************
******************* Construction of Figure B3 for Bangladesh *******************
********************************************************************************
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Paper - Awareness (BD + India)\Main paper\Firoz_Data_Do file_18.02.2022\Data_Covid_BD_wave_1.dta", clear
order RECORD_ID VILLAGE_ID FAMILY_ID cov_trt treat Q1_1_1_wash Q1_1_2_Cover_mouth Q1_1_3_distance Q1_1_4_handshake Q1_1_5_healthy tot_ans all_ans market2 doctor2 entertainment2 religious2 wash2 avoid_physical2
g question1= Q1_1_1_wash 
g question2= Q1_1_2_Cover_mouth 
g question3= Q1_1_3_distance 
g question4= Q1_1_4_handshake 
g question5= Q1_1_5_healthy
table treat 
order RECORD_ID treat question*
keep RECORD_ID treat question*
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\figures.dta"
sort RECORD_ID
save,replace
g choice=1
keep RECORD_ID treat question1 choice
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\ques_1.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\figures.dta", clear
g choice=2
keep RECORD_ID treat question2 choice
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\ques_2.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\figures.dta", clear
g choice=3
keep RECORD_ID treat question3 choice
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\ques_3.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\figures.dta", clear
g choice=4
keep RECORD_ID treat question4 choice
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\ques_4.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\figures.dta", clear
g choice=5
keep RECORD_ID treat question5 choice
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\ques_5.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\ques_1.dta", clear
rename question1 question
save,replace
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\ques_2.dta", clear
rename question2 question
save,replace
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\ques_3.dta", clear
rename question3 question
save,replace
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\ques_4.dta", clear
rename question4 question
save,replace
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\ques_5.dta", clear
rename question5 question
save,replace
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\ques_1.dta", clear
append using "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\ques_2.dta"
append using "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\ques_3.dta"
append using "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\ques_4.dta"
append using "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\ques_5.dta"
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\cibar_figure_data.dta"
table question
table choice
table treat
label define choice 1 "Wash hands frequently" 2 "Cover while sneezing and coughing" 3 "Maintain a certain distance" 4 "Avoid physical contact" 5 "Keep away from healthy people if sick", replace
label values choice choice
sort RECORD_ID
sort RECORD_ID treat
save,replace
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\cibar_figure_data.dta", clear
//ssc install cibar
cibar question, over1(choice) over2(treat) graphopts(title("Bangladesh") subtitle("Awareness on Individual Aspects") ytitle("Proportion") yscale(range(0 1)) ylabel(0(0.2)1) legend(col(1))) 
graph save Graph "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\Figure_B3_BD.gph"
graph export "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\Figure_B3_BD.gph", as(png) replace
graph export "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\Figure_B3_BD.gph", as(tif) replace






********************************************************************************
******************* Construction of Figure B4 for Bangladesh ************************
********************************************************************************
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Paper - Awareness (BD + India)\Main paper\Firoz_Data_Do file_18.02.2022\Data_Covid_BD_wave_1.dta", clear
order RECORD_ID VILLAGE_ID FAMILY_ID cov_trt treat Q1_1_1_wash Q1_1_2_Cover_mouth Q1_1_3_distance Q1_1_4_handshake Q1_1_5_healthy tot_ans all_ans market2 doctor2 entertainment2 religious2 wash2 avoid_physical2
summ market2 doctor2 entertainment2 religious2 wash2 avoid_physical2
g practice1= market2
g practice2= doctor2
g practice3= entertainment2
g practice4= religious2
g practice5= wash2
g practice6= avoid_physical2
order RECORD_ID treat practice*
keep RECORD_ID treat practice*
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\figures_2.dta"
sort RECORD_ID
save,replace
g practice=1
keep RECORD_ID treat practice1 practice
rename practice1 outcome
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\practice_1.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\figures_2.dta", clear
g practice=2
keep RECORD_ID treat practice2 practice
rename practice2 outcome
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\practice_2.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\figures_2.dta", clear
g practice=3
keep RECORD_ID treat practice3 practice
rename practice3 outcome
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\practice_3.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\figures_2.dta", clear
g practice=4
keep RECORD_ID treat practice4 practice
rename practice4 outcome
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\practice_4.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\figures_2.dta", clear
g practice=5
keep RECORD_ID treat practice5 practice
rename practice5 outcome
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\practice_5.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\figures_2.dta", clear
g practice=6
keep RECORD_ID treat practice6 practice
rename practice6 outcome
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\practice_6.dta"

use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\practice_1.dta", clear
append using "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\practice_2.dta"
append using "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\practice_3.dta"
append using "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\practice_4.dta"
append using "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\practice_5.dta"
append using "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\practice_6.dta"
table treat
table outcome
table practice
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\practice_figure_dataset.dta"
sort RECORD_ID
save,replace
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\practice_figure_dataset.dta", clear
g outcome2=1-outcome if practice<5
replace outcome2=outcome if practice>=5
label define practice 1 "Going to the market" 2 "Going to the doctor" 3 "Going out for entertainment purpose" 4 "Going out for religious purpose" 5 "Wash hands frequently" 6 "Avoided physical contact"
label values practice practice
sort RECORD_ID
save,replace
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\practice_figure_dataset.dta", clear
cibar outcome2, over1(practice) over2(treat) graphopts(subtitle("A: Bangladesh") ytitle("Proportion") yscale(range(0 1)) ylabel(0(0.2)1) legend(symxsize(4) keygap(1)))
graph save Graph "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\Figure_B4_BD.gph"
graph export "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\Figure_B4_BD.png", as(png) replace
graph export "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_BD_FA\Figure_B4_BD.tif", as(tif) replace




********************************************************************************
******************* Construction of Figure B3 for India ************************
********************************************************************************
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\Data_Covid_India.dta", clear
g question1= wash_hands
g question2= sneezing
g question3= distance
g question4= physical_contact
g question5= healthy
order uniq_id treat question*
keep uniq_id treat question*
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\figures.dta"
sort uniq_id
save,replace
g choice=1
keep uniq_id treat question1 choice
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\ques_1.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\figures.dta", clear
g choice=2
keep uniq_id treat question2 choice
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\ques_2.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\figures.dta", clear
g choice=3
keep uniq_id treat question3 choice
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\ques_3.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\figures.dta", clear
g choice=4
keep uniq_id treat question4 choice
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\ques_4.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\figures.dta", clear
g choice=5
keep uniq_id treat question5 choice
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\ques_5.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\ques_1.dta", clear
rename question1 question
save,replace
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\ques_2.dta", clear
rename question2 question
save,replace
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\ques_3.dta", clear
rename question3 question
save,replace
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\ques_4.dta", clear
rename question4 question
save,replace
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\ques_5.dta", clear
rename question5 question
save,replace
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\ques_1.dta", clear
append using "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\ques_2.dta"
append using "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\ques_3.dta"
append using "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\ques_4.dta"
append using "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\ques_5.dta"
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\cibar_figure_data.dta"
table question
table choice
table treat
label define choice 1 "Wash hands frequently" 2 "Cover while sneezing and coughing" 3 "Maintain a certain distance" 4 "Avoid physical contact" 5 "Keep away from healthy people if sick", replace
label values choice choice
sort uniq_id
save,replace
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\cibar_figure_data.dta", clear
//ssc install cibar
cibar question, over1(choice) over2(treat) graphopts(title("India") subtitle("Awareness on Individual Aspects") ytitle("Proportion") yscale(range(0 1)) ylabel(0(0.2)1) legend(col(1))) 
graph save Graph "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\Figure_B3_India.gph"
graph export "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\Figure_B3_India.gph", as(png) replace
graph export "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\Figure_B3_India.tif", as(tif) replace





********************************************************************************
******************* Construction of Figure B4 for India ************************
********************************************************************************
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\Data_Covid_India.dta", clear
order location id uniq_id treat market3 doctor3 entertainment2 religious2 hands_practice2 wash_practice2
save,replace
g practice1= market3
g practice2= doctor3
g practice3= entertainment2
g practice4= religious2
g practice5= wash_practice2
g practice6= hands_practice2
order uniq_id treat practice*
keep uniq_id treat practice*
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\figures_2.dta"
sort uniq_id
save,replace
g practice=1
keep uniq_id treat practice1 practice
rename practice1 outcome
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\practice_1.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\figures_2.dta", clear
g practice=2
keep uniq_id treat practice2 practice
rename practice2 outcome
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\practice_2.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\figures_2.dta", clear
g practice=3
keep uniq_id treat practice3 practice
rename practice3 outcome
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\practice_3.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\figures_2.dta", clear
g practice=4
keep uniq_id treat practice4 practice
rename practice4 outcome
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\practice_4.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\figures_2.dta", clear
g practice=5
keep uniq_id treat practice5 practice
rename practice5 outcome
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\practice_5.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\figures_2.dta", clear
g practice=6
keep uniq_id treat practice6 practice
rename practice6 outcome
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\practice_6.dta"
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\practice_1.dta", clear
append using "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\practice_2.dta"
append using "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\practice_3.dta"
append using "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\practice_4.dta"
append using "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\practice_5.dta"
append using "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\practice_6.dta"
table treat
table outcome
table practice
save "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\practice_figure_dataset.dta"
sort uniq_id
save,replace
use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\practice_figure_dataset.dta", clear
g outcome2=1-outcome if practice<5
replace outcome2=outcome if practice>=5
label define practice 1 "Going to the market" 2 "Going to the doctor" 3 "Going out for entertainment purpose" 4 "Going out for religious purpose" 5 "Wash hands frequently" 6 "Avoided physical contact"
label values practice practice
sort uniq_id
save,replace

use "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\practice_figure_dataset.dta", clear
cibar outcome2, over1(practice) over2(treat) graphopts(subtitle("B: India") ytitle("Proportion") yscale(range(0 1)) ylabel(0(0.2)1) legend(symxsize(4) keygap(1)))

graph save Graph "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\Figure_B4_India.gph"
graph export "C:\Users\ge86bac\Dropbox\COVID-19_BD_India\Extra\Figure_India_FA\Figure_B4_India.tif", as(tif) replace


//End of do-file
